<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="../include/laypublic.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>项目预(结)算复制</title>
</head>
<style>
#contract-breakdown {
	cursor: pointer;
}

#contract-investment-info .layui-inline .layui-form-label {
	position: relative;
	text-align: left;
}

#contract-investment-info .layui-inline .layui-form-label {
	position: relative;
	text-align: left;
}

#contract-investment-info .layui-inline:nth-child(1) .layui-form-label {
	left: 160px;
}

#contract-investment-info .layui-inline:nth-child(2) .layui-form-label {
	left: 120px;
}

#contract-investment-info .layui-inline:nth-child(3) .layui-form-label {
	left: 115px;
}

.margin-lt10 {
	margin-left: 10px;
}

.layui-row+.layui-row {
	margin-top: 36px;
}

.tg-l {
	text-align: left;
}

.tg-c {
	text-align: center;
}

.tg-r {
	text-align: right;
}

.contract-list {
	margin-top: 20px;
}

.contract-box {
	width: 100%;
	min-height: 100px;
}

.contract-money {
	width: 94%;
	margin: 0 auto;
}

.contract-money .layui-table {
	margin: 0;
}

.contract-money th {
	text-align: center;
	height: 38px;
}

.contract-money .label {
	display: block;
	width: 45px !important;
	text-align: left;
	margin-left: 15px;
}

.fieldset {
	margin-top: 5px;
	margin-bottom: 0px
}

.layui-legend {
	background-color: #5fb878;
	font-size: 15px !important;
	width: 140px;
}

.layui-form-item {
	margin-bottom: 5px;
	clear: both;
	*zoom: 1;
}

.layui-form-label {
	width: 160px;
}

.bankRow+.bankRow {
	border-top: 1px solid #e0e0e0;
	margin-top: 20px;
	padding-top: 20px;
}
</style>
<body>
	<div class="layui-fluid">
		<div class="layui-card">
			<div style="padding-top: 15px;">&nbsp;</div>
			<form class="layui-form" id="addInfo_form" lay-filter="addInfo_form">
				<div class="layui-tab layui-tab-brief" >
					<div class="layui-tab-content">
						<div class="layui-tab-item layui-show">
							<fieldset class="layui-elem-field layui-field-title fieldset"
								id="baseInfo">
								<legend class="layui-btn layui-legend"
									style="text-align: left; cursor: default;">项目基础信息></legend>
								<div class="layui-form-item">
									<div class="layui-inline">
										<label class="layui-form-label">申请公司</label>
										<div class="layui-input-inline">
											<input type="hidden" name="hrOrgid" value="${bindOrgId}">
											<input type="text" value="${bindOrgName}"
												style="border: 0px;" readonly="readonly" class="layui-input">
										</div>
									</div>
									<div class="layui-inline">
										<label class="layui-form-label">申请部门</label>
										<div class="layui-input-inline">
											<input type="hidden" name="hrDeptid" value="${bindDeptId}">
											<input type="text" value="${bindDeptName}"
												style="border: 0px;" readonly="readonly" class="layui-input">
										</div>
									</div>
									<div class="layui-inline">
										<label class="layui-form-label">申请人</label>
										<div class="layui-input-inline">
											<input type="hidden" name="hrStaffApplyid"
												value="${SESSION_KEY_USER_DETAIL.hrStaffId }"> <input
												type="text" name="staffname" value="${SESSION_KEY_USER_DETAIL.realName }"
												readonly="readonly" style="border: 0px" autocomplete="off"
												class="layui-input">
										</div>
									</div>
								</div>
								<div class="layui-form-item">
									<div class="layui-inline">
										<label class="layui-form-label">项目名称</label>
										<div class="layui-input-inline">
											<input type="text" name="proNames" value="${proSettleVo.proName}" 
												style="border:0px;width:265px" readonly="readonly" class="layui-input">
											<input type="hidden" name="proCodeAndCodes" value="${proSettleVo.proCode}_${proSettleVo.refId}_${proSettleVo.proName}"
												style="border:0px;width:220px" readonly="readonly" class="layui-input">
										</div>
									</div>
									<div class="layui-inline">
										<label class="layui-form-label">区域公司</label>
										<div class="layui-input-inline">
											<input type="text" value="${proSettleVo.orgAreaName}" id ="query-input-hrOrgAreName" style="border: 0px;width:220px" 
										 		 readonly="readonly" class="layui-input">
											<input type="hidden" name="hrOrgAreaId" value="${proSettleVo.hrOrgAreaId}" id ="query-input-hrOrgAreName" style="border: 0px;width:220px" 
										 		 readonly="readonly" class="layui-input">
										</div>
									</div>
									<div class="layui-inline">
										<label class="layui-form-label">项目公司</label>
										<div class="layui-input-inline">
											<input type="hidden" id="sgCityId" name="sgCityId" value="${proSettleVo.sgCityId}">
											<input type="text" value="${proSettleVo.orgProName}" id ="query-input-hrOrgAreName" style="border: 0px;width:220px" 
										 		 readonly="readonly" class="layui-input">
											<input type="hidden" name="hrOrgProId" value="${proSettleVo.hrOrgProId}" id ="query-input-hrOrgAreName" style="border: 0px;width:220px" 
										 		 readonly="readonly" class="layui-input">
										</div>
									</div>									
								</div>
								<div class="layui-form-item">									
									<div class="layui-inline">
										<label class="layui-form-label">实施机构</label>
										<div class="layui-input-inline">
											<input type="text" value="${proSettleVo.carryOrg}" id="id_ImplementingBody" name="carryOrg"
												style="border: 0px;" readonly="readonly" class="layui-input">
										</div>
									</div>
									<div class="layui-inline">
										<label class="layui-form-label">项目负责人</label>
										<div class="layui-input-inline">
											<input type="text" value="${proSettleVo.proLeader}" id="id_projectLeader" name="proLeader"
												style="border: 0px;" readonly="readonly" class="layui-input">
										</div>
									</div>
									<div class="layui-inline">
										<label class="layui-form-label">预算类型</label>
										<div class="layui-input-inline">
											<select id="add_select_budgetType" name="budgetType"
												lay-filter="add_select_budgetType" lay-verify="required">
												<option value="">请选择</option>
												<option value="1" <c:if test="${proSettleVo.budgetType == '1' }">selected</c:if>>认质认价</option>
												<option value="2" <c:if test="${proSettleVo.budgetType == '2' }">selected</c:if>>签证</option>
												<option value="3" <c:if test="${proSettleVo.budgetType == '3' }">selected</c:if>>变更</option>
												<option value="4" <c:if test="${proSettleVo.budgetType == '4' }">selected</c:if>>索赔</option>
												<option value="5" <c:if test="${proSettleVo.budgetType == '5' }">selected</c:if>>补偿</option>
												<option value="6" <c:if test="${proSettleVo.budgetType == '6' }">selected</c:if>>施工图预算</option>
												<option value="7" <c:if test="${proSettleVo.budgetType == '7' }">selected</c:if>>财评价</option>
												<option value="8" <c:if test="${proSettleVo.budgetType == '8' }">selected</c:if>>甩项</option>
												<option value="9" <c:if test="${proSettleVo.budgetType == '9' }">selected</c:if>>结算</option>
											</select>
										</div>
									</div>
								</div>
								<div class="layui-form-item">
									<div class="layui-inline">
										<label class="layui-form-label">本次预（结）算金额（元）</label>
										<div class="layui-input-inline">
											<c:if test="${proSettleVo.budgetType != '1'}">
												<input type="text" name="totalSum" value="${proSettleVo.totalSum }"
													style="border: 0px;" readonly="readonly" class="layui-input">
											</c:if>
											<c:if test="${proSettleVo.budgetType == '1'}">
												<input type="text" name="totalSum" value="0"
													style="border: 0px;" readonly="readonly" class="layui-input">
											</c:if>
										</div>
									</div>	
									<div class="layui-inline" id="caegrossAdjustDiv" <c:if test="${proSettleVo.budgetType != '9'}">style="display:none"</c:if>>
										<label class="layui-form-label">建安毛利调整额（元）（选填）</label>
										<div class="layui-input-inline">
											<input type="text" id="id_caegrossAdjust" name="caeGrossAdjust"	 value="<c:if test="${proSettleVo.budgetType == '9'}">${proSettleVo.caeGrossAdjust }</c:if>"		
												placeholder="请输入建安毛利调整额" autocomplete="off" maxlength="13"
												onblur="isNumberAndFloat(this);arabiaToCN(this,1);" class="layui-input">
										</div>
									</div>
								</div>								
							</fieldset>
							<fieldset class="layui-elem-field layui-field-title fieldset"
								id="baseInfo">
								<legend class="layui-btn layui-legend" style="text-align: left; cursor: default;">合同费用信息></legend>
								<div class="layui-form-item">
									<div class="layui-inline">
										<label class="layui-form-label">序号</label>
										<div class="layui-input-inline">
											<input type="text" name="index"
												readonly="readonly" style="border: 0px" class="layui-input">
										</div>
									</div>
									<div class="layui-inline">
										<label class="layui-form-label">费用名称</label>
										<div class="layui-input-inline">
											<input type="text" name="feeName"
												readonly="readonly" style="border: 0px" class="layui-input">
										</div>
									</div>
									<div class="layui-inline">
										<label class="layui-form-label">金额（元）</label>
										<div class="layui-input-inline">
											<input type="text" name="cost"
												readonly="readonly" style="border: 0px" class="layui-input">
										</div>
									</div>
								</div>
								<div class="layui-form-item">
									<!-- 灰色分割线 -->
									<!-- 	<hr class="layui-bg-gray">-->
								</div>
							</fieldset>
							
							<fieldset class="layui-elem-field layui-field-title fieldset" id="contract-investment-info" >
								<div class="layui-form-item" >
									<div class="layui-inline" >
										<label class="layui-form-label">1</label>
										<div class="layui-input-inline"></div>
									</div>
									<div class="layui-inline">
										<label class="layui-form-label">建安工程费</label>
										<div class="layui-input-inline"></div>
									</div>
									<div class="layui-inline">
										<label class="layui-form-label" id="caeFeeLabel">${proSettleVo.proSettleFee.caeFee}</label>
										<div class="layui-input-inline" ><input type="hidden" id="caeFeeId" name="caeFee" value="${proSettleVo.proSettleFee.caeFee}" /></div>
									</div>
								</div>
								<div class="layui-form-item">
									<div class="layui-inline">
										<label class="layui-form-label"></label>
										<div class="layui-input-inline"></div>
									</div>
									<div class="layui-inline">
										<label class="layui-form-label " style="left:130px;" >*建安下浮率（综合）</label>
										<div class="layui-input-inline"></div>
									</div>
									<div class="layui-inline">
										<label class="layui-form-label" id="caeDownRateLabel">${proSettleVo.proSettleFee.caeDownRate}</label>
										<div class="layui-input-inline" ><input type="hidden" id="caeDownRateId" name="caeDownRate" value="${proSettleVo.proSettleFee.caeDownRate}" /></div>
									</div>
								</div>
								<div class="layui-form-item">
									<div class="layui-inline">
										<label class="layui-form-label"></label>
										<div class="layui-input-inline"></div>
									</div>
									<div class="layui-inline">
										<label class="layui-form-label" style="left:130px;"  >*建安占比</label>
										<div class="layui-input-inline"></div>
									</div>
									<div class="layui-inline">
										<label class="layui-form-label" id="caeRateLabel">${proSettleVo.proSettleFee.caeRate}</label>
										<div class="layui-input-inline"><input type="hidden" id="caeRateId" name="caeRate" value="${proSettleVo.proSettleFee.caeRate}" /></div>
									</div>
								</div>
								<div class="layui-form-item">
									<div class="layui-inline">
										<label class="layui-form-label">2</label>
										<div class="layui-input-inline"></div>
									</div>
									<div class="layui-inline">
										<label class="layui-form-label">预备费</label>
										<div class="layui-input-inline"></div>
									</div>
									<div class="layui-inline">
										<label class="layui-form-label" id="prepareFeeLabel">${proSettleVo.proSettleFee.prepareFee}</label>
										<div class="layui-input-inline" ><input type="hidden" id="prepareFeeId" name="prepareFee" value="${proSettleVo.proSettleFee.prepareFee}" /></div>
									</div>
								</div>
								<div class="layui-form-item">
									<div class="layui-inline">
										<label class="layui-form-label">3</label>
										<div class="layui-input-inline"></div>
									</div>
									<div class="layui-inline">
										<label class="layui-form-label">建安工程其他费</label>
										<div class="layui-input-inline" ></div>
									</div>
									<div class="layui-inline">
										<label class="layui-form-label" id="buildOtherFeeLabel">${proSettleVo.proSettleFee.buildOtherFee}</label>
										<div class="layui-input-inline" ><input type="hidden" id="buildOtherFeeId" name="buildOtherFee" value="${proSettleVo.proSettleFee.buildOtherFee}" /></div>
									</div>
								</div>
								<div class="layui-form-item">
									<div class="layui-inline">
										<label class="layui-form-label">3.1</label>
										<div class="layui-input-inline"></div>
									</div>
									<div class="layui-inline">
										<label class="layui-form-label">建设单位管理费</label>
										<div class="layui-input-inline"></div>
									</div>
									<div class="layui-inline">
										<label class="layui-form-label" id="buildOrgFeeLabel">${proSettleVo.proSettleFee.buildOrgFee}</label>
										<div class="layui-input-inline" ><input type="hidden" id="buildOrgFeeId" name="buildOrgFee" value="${proSettleVo.proSettleFee.buildOrgFee}" /></div>
									</div>
								</div>
								<div class="layui-form-item">
									<div class="layui-inline">
										<label class="layui-form-label">3.2</label>
										<div class="layui-input-inline"></div>
									</div>
									<div class="layui-inline">
										<label class="layui-form-label">政府代付费</label>
										<div class="layui-input-inline"></div>
									</div>
									<div class="layui-inline">
										<label class="layui-form-label" id="gdReplaceFeeLabel">${proSettleVo.proSettleFee.gdReplaceFee}</label>
										<div class="layui-input-inline"><input type="hidden" id="gdReplaceFeeId" name="gdReplaceFee" value="${proSettleVo.proSettleFee.gdReplaceFee}" /></div>
									</div>
								</div>
								<div class="layui-form-item">
									<div class="layui-inline">
										<label class="layui-form-label">3.3</label>
										<div class="layui-input-inline"></div>
									</div>
									<div class="layui-inline">
										<label class="layui-form-label">项目前期费</label>
										<div class="layui-input-inline"></div>
									</div>
									<div class="layui-inline">
										<label class="layui-form-label" id="preFeeLabel">${proSettleVo.proSettleFee.preFee}</label>
										<div class="layui-input-inline"><input type="hidden" id="preFeeId" name="preFee" value="${proSettleVo.proSettleFee.preFee}" /></div>
									</div>
								</div>
								<div class="layui-form-item">
									<div class="layui-inline">
										<label class="layui-form-label">3.3.1</label>
										<div class="layui-input-inline"></div>
									</div>
									<div class="layui-inline">
										<label class="layui-form-label">征地拆迁费</label>
										<div class="layui-input-inline"></div>
									</div>
									<div class="layui-inline">
										<label class="layui-form-label" id="moveFeeLabel">${proSettleVo.proSettleFee.moveFee}</label>
										<div class="layui-input-inline"><input type="hidden" id="moveFeeId" name="moveFee" value="${proSettleVo.proSettleFee.moveFee}" /></div>
									</div>
								</div>
								<div class="layui-form-item">
									<div class="layui-inline">
										<label class="layui-form-label">4</label>
										<div class="layui-input-inline"></div>
									</div>
									<div class="layui-inline">
										<label class="layui-form-label">建设期利息</label>
										<div class="layui-input-inline"></div>
									</div>
									<div class="layui-inline">
										<label class="layui-form-label" id="buildInterestLabel">${proSettleVo.proSettleFee.buildInterest}</label>
										<div class="layui-input-inline"><input type="hidden" id="buildInterestId" name="buildInterest" value="${proSettleVo.proSettleFee.buildInterest}" /></div>
									</div>
								</div>
								<div class="layui-form-item">
									<div class="layui-inline">
										<label class="layui-form-label">5</label>
										<div class="layui-input-inline"></div>
									</div>
									<div class="layui-inline">
										<label class="layui-form-label">设备及工器具购置</label>
										<div class="layui-input-inline"></div>
									</div>
									<div class="layui-inline">
										<label class="layui-form-label" id="buyFeeLabel">${proSettleVo.proSettleFee.buyFee}</label>
										<div class="layui-input-inline"><input type="hidden" id="buyFeeId" name="buyFee" value="${proSettleVo.proSettleFee.buyFee}" /></div>
									</div>
								</div>
								<div class="layui-form-item">
									<div class="layui-inline">
										<label class="layui-form-label">6</label>
										<div class="layui-input-inline"></div>
									</div>
									<div class="layui-inline">
										<label class="layui-form-label">铺底流动资金</label>
										<div class="layui-input-inline"></div>
									</div>
									<div class="layui-inline">
										<label class="layui-form-label" id="flowFeeLabel">${proSettleVo.proSettleFee.flowFee}</label>
										<div class="layui-input-inline"><input type="hidden" id="flowFeeId" name="flowFee" value="${proSettleVo.proSettleFee.flowFee}" /></div>
									</div>
								</div>
								<div class="layui-form-item">
									<hr class="layui-bg-gray">
								</div>
								<div class="layui-form-item">
									<div class="layui-inline">
										<label class="layui-form-label"></label>
										<div class="layui-input-inline"></div>
									</div>
									<div class="layui-inline">
										<label class="layui-form-label">投资合计</label>
										<div class="layui-input-inline" ></div>
									</div>
									<div class="layui-inline">
										<label class="layui-form-label" id="totalSumLabel">${proSettleVo.proSettleFee.totalSum}</label>
										<div class="layui-input-inline" ><input type="hidden"  id="totalSumId" name="totalSumFee" value="${proSettleVo.proSettleFee.totalSum}"  />
										</div>
									</div>
								</div>
							</fieldset>
							
							<fieldset class="layui-elem-field layui-field-title fieldset"
								id="proSettleInfo" <c:if test="${proSettleVo.budgetType == '1'}">style="display:none;"</c:if>>
								<legend class="layui-btn layui-legend"
									style="text-align: left; cursor: default;">预(结)算信息></legend>
								<div style="margin-top:20px">
							  		<div class="layui-form-item" style="margin: 0 20px;">
							  			<table class="layui-table layuiadmin-page-table" lay-skin="line">
							  			     <colgroup>
						                        <col width="60"  >
						                        <col width="100" >
						                        <col width="140" >
						                        <col width="140" >
						                        <col width="120" >
						                        <col width="100" >
						                        <col width="100" >
						                        <col width="120" >
						                        <col width="100" >
						                        <col width="100" >
						                    </colgroup>
							  				<thead>
							                    <tr>
							                      <th></th>
							                      <th></th>
							                      <th></th>
							                      <th></th>
							                      <th>项目合同金(下浮后)(元)</th>
							                      <th>申报金额(元)</th>
							                      <th>审定金额(元)</th>
							                      <th>审核增减金额(元)</th>
							                      <th>审核增减率(%)</th>
							                      <th></th>
							                    </tr> 
							                    <tr>
							                      <td>合计</td>
							                      <td></td>
							                      <td></td>
							                      <td></td>
							                      <td><input type="text" id="cotAmountAfterId" value="${proSettleVo.cotAmountAfter}" name="cotAmountAfter" style="border:0px;" readonly="readonly" class="layui-input"></td>
							                      <td><input type="text" id="applyAmountId" value="${proSettleVo.applyAmount}" name="applyAmount" style="border: 0px; " readonly="readonly" class="layui-input"></td>
							                      <td><input type="text" id="checkAmountId" value="${proSettleVo.checkAmount}" name="checkAmount" style="border: 0px;" readonly="readonly" class="layui-input"></td>
							                      <td><input type="text" id="checkAmountReviseId" value="${proSettleVo.checkAmountRevise}" name="checkAmountRevise" style="border: 0px; " readonly="readonly" class="layui-input"></td>
							                      <td><input type="text" id="checkReviseRateId" value="${proSettleVo.checkReviseRate}" name="checkReviseRate" style="border: 0px;" readonly="readonly" class="layui-input"></td>
							                      <td></td>
							                    </tr> 
						                  	</thead>
						                  <thead>
						                    <tr>
						                      <th>序号</th>
						                      <th>事项名称</th>
						                      <th>项目子项(选填)</th>
						                      <th>费用类别</th>
						                      <th>项目合同金(下浮后)(元)</th>
						                      <th>申报金额(元)</th>
						                      <th>审定金额(元)</th>
						                      <th>审核增减金额(元)</th>
						                      <th>审核增减率(%)</th>
						                      <th></th>
						                    </tr> 
						                  </thead>
						                  <tbody id="details">
						                  <c:forEach items="${proSettleVo.proSettleDetails}" var="detail" varStatus="status">
							                  	<tr id="linkRow${status.count }">
													<td><input type="text" name="showIdxs" value="${detail.showIdx }" style="border: 0px;width:50px" readonly="readonly" class="layui-input prosettles"></td>
													<td><input type="text" name="itemNames" value="${detail.itemName}" class="layui-input prosettles"></td>
													<td id="select_subname">
														<select id="add_select_subName" name="subNames" lay-filter="add_select_subName" lay-search>
												      		<option value="-1">请选择</option>
											      				<c:if test="${not empty contractExtSubList }">
											              			<c:forEach items="${contractExtSubList}" var="contractExtSub">
											              				<option value="${contractExtSub.subName}" <c:if test="${contractExtSub.subName == detail.subName}">selected</c:if>>${contractExtSub.subName}</option>
												            		</c:forEach>
											              		</c:if>
											      		</select>
													</td>
													<td>
										      			<select  name="feeTypes"  lay-verify="required" lay-search>
															<option value="">请选择</option>
															<option value="1" <c:if test="${detail.feeType == '1'}">selected</c:if>>建安工程费</option>
															<option value="2" <c:if test="${detail.feeType == '2'}">selected</c:if>>预备费</option>
															<option value="3" <c:if test="${detail.feeType == '3'}">selected</c:if>>建设工程其他费</option>
															<option value="31" <c:if test="${detail.feeType == '31'}">selected</c:if>>建设单位管理费</option>
															<option value="32" <c:if test="${detail.feeType == '32'}">selected</c:if>>政府代付费</option>
															<option value="33" <c:if test="${detail.feeType == '33'}">selected</c:if>>项目前期费</option>
															<option value="4" <c:if test="${detail.feeType == '4'}">selected</c:if>>建设期利息</option>
															<option value="5" <c:if test="${detail.feeType == '5'}">selected</c:if>>设备及工器具购置</option>
															<option value="6" <c:if test="${detail.feeType == '6'}">selected</c:if>>铺底流动资金</option>
														</select>
													</td>
													<td><input type="text" name="cotAmountAfters" value="${detail.cotAmountAfter}" onblur="calcSumAmount(this);arabiaToCN(this,1);" maxlength="13" lay-verify="required|floatNumber"  autocomplete="off" class="layui-input prosettles"></td>
													<td><input type="text" id="applyAmount-${status.count}" name="applyAmounts" value="${detail.applyAmount}" onblur="calcSumAmount(this);arabiaToCN(this,1);" maxlength="13" lay-verify="required|floatNumber"  autocomplete="off" class="layui-input prosettles"></td>
													<td><input type="text" id="checkAmount-${status.count}" name="checkAmounts" value="${detail.checkAmount}" onblur="calcSumAmount(this);arabiaToCN(this,1);" maxlength="13" lay-verify="required|floatNumber"  autocomplete="off" class="layui-input prosettles"></td>				
													<td><input type="text" id="checkAmountRevise-${status.count}" name="checkAmountRevises" value="${detail.checkAmountRevise}"  style="border: 0px;width:90px;" lay-verify="required|floatNumber" readonly="readonly" class="layui-input prosettles"></td>
													<td><input type="text" id="checkReviseRate-${status.count}" name="checkReviseRates" value="${detail.checkReviseRate}" style="border: 0px;" lay-verify="required|floatNumber" readonly="readonly" class="layui-input prosettles"></td>
													<td>
												    	<button type="button" class="layui-btn layui-btn-sm" id="addSettleBtn${status.count}" onclick="addSettleRow(this);"><i class="layui-icon">&#xe654;</i></button>
												    	<button type="button" class="layui-btn layui-btn-sm" style="display:none" id="delSettleBtn${status.count}" onclick="delSettleRow(${status.count})"><i class="layui-icon">&#xe640;</i></button>
													</td>
												</tr>
												</c:forEach>
						                  </tbody>
						                </table>
								    </div>
							  	</div>
							  	<div class="layui-form-item">
									<div class="layui-inline">
										<label class="layui-form-label">情况说明</label>
										<div class="layui-input-inline">
											<textarea placeholder="请输入最多500字" id="memoId" name="memo"
												class="layui-textarea" maxlength="500" lay-verify="required"
												style="width: 899px; height: 90px;">${proSettleVo.memo }</textarea>
										</div>
									</div>
								</div>
							</fieldset>
							
							<fieldset class="layui-elem-field layui-field-title fieldset"
								id="perceivedValue" <c:if test="${proSettleVo.budgetType != '1'}">style="display:none"</c:if>>
								<legend class="layui-btn layui-legend"
									style="text-align: left; cursor: default;">认质认价信息></legend>
								<div class="layui-form-item">
									<!-- 灰色分割线 -->
									<hr class="layui-bg-gray">
								</div>
								<div class="layui-form-item">
									<div class="layui-inline">
										<label class="layui-form-label">认质认价名称</label>
										<div class="layui-input-inline">
											<input type="text" id="perceiveNameId" value="${proSettleVo.perceiveName}" name="perceiveName" placeholder="请输入认质认价名称"
												maxlength="50" autocomplete="off"
												class="layui-input">
										</div>
									</div>
								</div>
								<div class="layui-form-item" >
									<div class="layui-inline">
										<label class="layui-form-label">认质认价情况说明</label>
										<div class="layui-input-inline">
											<textarea placeholder="请输入最多500字" id="perceiveMemoId" name="perceiveMemo"
												class="layui-textarea" maxlength="500" style="width:899px; height:90px;" >${proSettleVo.perceiveMemo }</textarea>
										</div>
									</div>
								</div>
							</fieldset>
							<fieldset class="layui-elem-field layui-field-title fieldset"
								id="baseInfo">
								<legend class="layui-btn layui-legend"
									style="text-align: left; cursor: default;">附件></legend>
								<div style="margin-top: 20px;">
									<div class="layui-form-item">
										<label class="layui-form-label" style="width: 350px;">支持pdf、excel、word、图片资料，可上传多个</label>
									</div>
									<div class="layui-form-item">
										<label class="layui-form-label">计算稿（选填）</label>
										<div class="layui-input-block">
											<div class="layui-upload">
												<button type="button" class="layui-btn" id="1-upload-more">上传</button>
												<div class="layui-upload-list" id="1-upload-more-list">
												<c:forEach items="${proSettleVo.proSettleAtts }" var="fileAtt">
							              			<c:if test="${fileAtt.types == '1' }">
							              				<div class="layui-upload-img-div" id="upload_img_${fileAtt.id }">
							              					<c:choose>
								              					<c:when test="${fileAtt.fileSuffix == '.jpg' or fileAtt.fileSuffix == '.jpeg' or fileAtt.fileSuffix == '.png'}">
									              					<img src="${fileHttpPre }/${fileAtt.filePath }" title="${fileAtt.fileName}" class="layui-upload-img">
									              				</c:when>
									              				<c:otherwise>
									              					<img src="${ctx}/resources/images/${fn:substring(fileAtt.fileSuffix,1,5)}.jpg" title="${fileAtt.fileName}" class="layui-upload-img">
									              				</c:otherwise>
							              					</c:choose>
							              					<div class="mask">
							              						<a href="javascript:void(0)" onclick="showImg('${fileHttpPre}/${fileAtt.filePath }');">查看</a>
							              						<a href="javascript:void(0)" onclick="del('${fileAtt.id}')">删除</a>
							              						<input type="hidden" value="${fileAtt.types}|${fileAtt.fileName}${fileAtt.fileSuffix }||${fileAtt.filePath }" id="fileAtt_${fileAtt.id}" name="fileAtts1" ></input>
							              					</div>
							              					<p>${fileAtt.fileName}</p>
							              				</div>
							              			</c:if>
							              		</c:forEach>
												</div>
											</div>
										</div>
									</div>
									<div class="layui-form-item">
										<label class="layui-form-label">签字扫描件（选填）</label>
										<div class="layui-input-block">
											<div class="layui-upload">
												<button type="button" class="layui-btn" id="2-upload-more">上传</button>
												<div class="layui-upload-list" id="2-upload-more-list">
												<c:forEach items="${proSettleVo.proSettleAtts }" var="fileAtt">
							              			<c:if test="${fileAtt.types == '2' }">
							              				<div class="layui-upload-img-div" id="upload_img_${fileAtt.id }">
							              					<c:choose>
								              					<c:when test="${fileAtt.fileSuffix == '.jpg' or fileAtt.fileSuffix == '.jpeg' or fileAtt.fileSuffix == '.png'}">
									              					<img src="${fileHttpPre }/${fileAtt.filePath }" title="${fileAtt.fileName}" class="layui-upload-img">
									              				</c:when>
									              				<c:otherwise>
									              					<img src="${ctx}/resources/images/${fn:substring(fileAtt.fileSuffix,1,5)}.jpg" title="${fileAtt.fileName}" class="layui-upload-img">
									              				</c:otherwise>
							              					</c:choose>
							              					<div class="mask">
							              						<a href="javascript:void(0)" onclick="showImg('${fileHttpPre}/${fileAtt.filePath }');">查看</a>
							              						<a href="javascript:void(0)" onclick="del('${fileAtt.id}')">删除</a>
							              						<input type="hidden" value="${fileAtt.types}|${fileAtt.fileName}${fileAtt.fileSuffix }||${fileAtt.filePath }" id="fileAtt_${fileAtt.id}" name="fileAtts2" ></input>
							              					</div>
							              					<p>${fileAtt.fileName}</p>
							              				</div>
							              			</c:if>
							              		</c:forEach>
												</div>
											</div>
										</div>
									</div>
									<div class="layui-form-item">
										<label class="layui-form-label">其他附件（选填）</label>
										<div class="layui-input-block">
											<div class="layui-upload">
												<button type="button" class="layui-btn" id="3-upload-more">上传</button>
												<div class="layui-upload-list" id="3-upload-more-list">
												<c:forEach items="${proSettleVo.proSettleAtts }" var="fileAtt">
							              			<c:if test="${fileAtt.types == '3' }">
							              				<div class="layui-upload-img-div" id="upload_img_${fileAtt.id }">
							              					<c:choose>
								              					<c:when test="${fileAtt.fileSuffix == '.jpg' or fileAtt.fileSuffix == '.jpeg' or fileAtt.fileSuffix == '.png'}">
									              					<img src="${fileHttpPre }/${fileAtt.filePath }" title="${fileAtt.fileName}" class="layui-upload-img">
									              				</c:when>
									              				<c:otherwise>
									              					<img src="${ctx}/resources/images/${fn:substring(fileAtt.fileSuffix,1,5)}.jpg" title="${fileAtt.fileName}" class="layui-upload-img">
									              				</c:otherwise>
							              					</c:choose>
							              					<div class="mask">
							              						<a href="javascript:void(0)" onclick="showImg('${fileHttpPre}/${fileAtt.filePath }');">查看</a>
							              						<a href="javascript:void(0)" onclick="del('${fileAtt.id}')">删除</a>
							              						<input type="hidden" value="${fileAtt.types}|${fileAtt.fileName}${fileAtt.fileSuffix }||${fileAtt.filePath }" id="fileAtt_${fileAtt.id}" name="fileAtts3" ></input>
							              					</div>
							              					<p>${fileAtt.fileName}</p>
							              				</div>
							              			</c:if>
							              		</c:forEach>
												</div>
											</div>
										</div>
									</div>
								</div>
							</fieldset>

						</div>
					</div>
				</div>

				<div class="layui-form-item"
					style="position: fixed ! important; right: 30px; bottom: 45%; z-index: 10000;">
					<div class="layui-input-block">
						<button
							class="layui-btn layui-bg-blue layui-btn-normal layui-btn-lg  layui-btn-radius"
							type="button" lay-submit lay-filter="addInfo_form_submit"
							id="addInfo_form_submit">
							<i class="layui-icon layui-icon-ok layuiadmin-button-btn"></i> 提交
						</button>
					</div>
				</div>
			</form>
		</div>
	</div>
</body>
</html>
<script>
String.prototype.toInt = function () {
	if(this==''){
		return 0;
	}
	return parseInt(this);
}
String.prototype.toFloat = function () {
	if(this==''){
		return 0;
	}
	return parseFloat(this);
}
Number.prototype.toMoney = function () {
	var m = Math.pow(10, 2);
	return Math.round(this * m) / m;
}

	var proName;
	var proNameid;
	//静态资源路径前缀
	var staticPath = '${fileHttpPre}';
	var stateJSON = <infopub:dicJson groupNo="A00010028" />;

	layui.config({
				base : '${ctx}/resources/layuiadmin/' //静态资源所在路径
			})
			.extend({
				index : 'lib/index' //主入口模块
			})
			.use(['index', 'set', 'upload', 'element', 'laydate' ],
					function() {
						
						var $ = layui.$, form = layui.form, element = layui.element, laydate = layui.laydate, upload = layui.upload;
						// 正则校验
						form.verify({
							//验证汉字
						    CHS:[
						    	/^[\u0391-\uFFE5]+$/
						    	,'只能输入汉字'
						  	],
						  	//名字校验
						  	COC: [
								/^[\u4e00-\u9fa5_a-zA-Z0-9]+$/
								,'请输入正确的名称'
						  	],
						  	//大于0的正整数
						  	intNumber:[
								/^[1-9]\d*$/
								,'请输入正确的数字'
						  	],
						  	//数字只能有两位小数
						  	floatNumber:[
								/^([-]?)([0-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/
								,'请输入正确的数字'
						  	],
						  	telNumber:[/^[1][3,4,5,7,8,9][0-9]{9}$/
								  		,'请输入正确的号码'
							],
						  	//数字大于等于0，并只能有两位小数
						  	floatAmount:[
								/^([0-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/
								//var pattern=/^((\d+\.\d*[1-9]\d{1})|(\d*[1-9]\d*\.\d{2}))$/; 
								,'请输入正确的数字'
						  	]
						});
						uploadRender(1,upload,$);
						uploadRender(2,upload,$);
						uploadRender(3,upload,$);
						
						form.on('select(add_select_proId)', function(data) {
							var id = data.value;
							proNameid = data.value;
							proName = data.elem.getAttribute('proName');
							if(id==''||id==null){
								layer.msg('请选择项目名称',{icon: 3});
								return;
							}else{
								getContractExtByProId(id);
							}						
						});
						form.on('select(add_select_budgetType)', function(data) {
							var budgetType = data.value;
							if(budgetType=='1'){
								$("#memoId").removeAttr("lay-verify");
								$('input[type=text].prosettles').removeAttr("lay-verify");
								$('select[name="feeTypes"]').removeAttr("lay-verify");
								$("#perceiveNameId").attr("lay-verify","required");
								$("#perceiveMemoId").attr("lay-verify","required");
								$("#perceivedValue").css('display','block');
								$("#proSettleInfo").css('display','none');
								$("#caegrossAdjustDiv").css('display','none');
								$("#id_totalSum").val('0');
								$("#id_caegrossAdjust").val('0');
								form.render();
							}else{
								if(budgetType=='9'){
									$("#caegrossAdjustDiv").css('display','inline-block');
								}else{
									$("#caegrossAdjustDiv").css('display','none');
									$("#id_caegrossAdjust").val('0');
								}
								$("#perceiveNameId").removeAttr("lay-verify");
								$("#perceiveMemoId").removeAttr("lay-verify");
								$("#memoId").attr("lay-verify","required");
								$('input[type=text].prosettles').attr("lay-verify","required");
								$('select[name="feeTypes"]').attr("lay-verify","required");
								$("#proSettleInfo").css('display','block');
								$("#perceivedValue").css('display','none');	
								$("#id_totalSum").val('');
								form.render();
							}
						});
						$(function () {
							var budgetType = $('#add_select_budgetType').val();
							if(budgetType=='1'){
								$("#memoId").removeAttr("lay-verify");
								$('input[type=text].prosettles').removeAttr("lay-verify");
								$('select[name="feeTypes"]').removeAttr("lay-verify");
								$("#perceiveNameId").attr("lay-verify","required");
								$("#perceiveMemoId").attr("lay-verify","required");
								$("#perceivedValue").css('display','block');
								$("#proSettleInfo").css('display','none');
								$("#caegrossAdjustDiv").css('display','none');
								$("#id_totalSum").val('0');
								$("#id_caegrossAdjust").val('0');
								form.render();
							}else{
								if(budgetType=='9'){
									$("#caegrossAdjustDiv").css('display','inline-block');
								}else{
									$("#caegrossAdjustDiv").css('display','none');
									$("#id_caegrossAdjust").val('0');
								}
								$("#perceiveNameId").removeAttr("lay-verify");
								$("#perceiveMemoId").removeAttr("lay-verify");
								$("#memoId").attr("lay-verify","required");
								$('input[type=text].prosettles').attr("lay-verify","required");
								$('select[name="feeTypes"]').attr("lay-verify","required");
								$("#proSettleInfo").css('display','block');
								$("#perceivedValue").css('display','none');	
								$("#id_totalSum").val('');
								form.render();
							}
						});
						form.on('submit(addInfo_form_submit)',function (data) {
		                	$("#addInfo_form_submit").removeAttr("lay-submit").removeClass("layui-bg-blue").addClass("layui-btn-disabled");
		              		layer.load();
		                   	//提交 Ajax 成功后，静态更新表格中的数据
		                   	$.ajax({
		                       	type : 'post',
		            			url : basePath + '/proSettle/save',
		                       	data: $('#addInfo_form').serialize(),
		            			success:function(result){
		            				if(result.success){
		            					layer.closeAll('loading'); //关闭loading
		            					layer.msg('提交单据成功~',{icon: 1});
		            					//两秒后关闭当前页面
		            					setTimeout(function(){
		            						/**
		            						 * 查找父菜单，并刷新
		            						 */
		            						var topDoc = $(window.top.document);
		            						var path = basePath + '/proSettle/list';
		            						// 获取页面名称
		            						var name = topDoc.find(".layui-nav-item [lay-href^='" + path + "']").text();
		            						if(name == '' || name == null){
		            							name = '项目预(结）算';
		            						}
		            						window.parent.layui.index.openTabsPage(path, name);
		            						var iframe = window.parent.layui.admin.tabsBody(window.parent.layui.admin.tabsPage.index).find(".layadmin-iframe");
		            						iframe[0].contentWindow.location.reload(true);
		            						
		            						/**
		            						 * 关闭当前页
		            						 */
		            						var currPath = basePath + '/proSettle/toCopy';
		            						var layid = topDoc.find("li[lay-id^='" + currPath + "']").attr('lay-id');
		            						window.parent.layui.element.tabDelete('layadmin-layout-tabs', layid);//关闭当前页
		            				        }, 2000);
		            				}else{
		            					layer.closeAll('loading'); //关闭loading
		              					$("#addInfo_form_submit").removeClass("layui-btn-disabled").addClass("layui-bg-blue").attr("lay-submit","");
		            					layer.msg(result.msg,{icon: 7});
		            			  	}
		            			}
		                   	});

		                });
		            });

	
    var uploadRender = function(id,upload,$) {
        upload.render({
                elem : '#' + id + '-upload-more',
                url : basePath
                    + '/proSettle/uploadAtt/',
                data : {
                    types : id
                },
                multiple : true,
                accept : 'file',
                acceptMime : 'application/zip,application/x-rar-compressed,image/jpeg,image/png,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.presentation,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/pdf',
                before : function(obj) {
                    layer.load();
                },
                done : function(res) {
                    if (res.code > 0) {
                        layer.closeAll('loading');
                        return layer.msg(res.msg, {
                            icon : 7
                        });
                    }
                    if (res.entity != null
                        && res.entity.length > 0) {
                        for ( var i in res.entity) {
                            var preProject = res.entity[i];
                            var arr = preProject
                                .split("|");
                            var imgSrc = "";
                            var suffix = arr[1]
                                .substring(
                                    arr[1]
                                        .lastIndexOf(".") + 1,
                                    arr[1].length);
                            if (suffix == 'jpg'
                                || suffix == 'png') {
                                imgSrc = "${fileHttpPre}/"
                                    + arr[3];
                            } else {
                                imgSrc = "${ctx}/resources/images/"
                                    + suffix
                                    + ".jpg";
                            }
                            $(
                                '#'
                                + id
                                + '-upload-more-list')
                                .append(
                                    '<div class="layui-upload-img-div" id="upload_img_'+arr[2]+'"><img src="'+imgSrc+'" title="'+ arr[1] +'" class="layui-upload-img"><div class="mask"><a href="javascript:void(0)" onclick="showImg(\''
                                    + "${fileHttpPre}"
                                    + arr[3]
                                    + '\');">查看</a><a href="javascript:void(0)" onclick="del(\''
                                    + arr[2]
                                    + '\')";>删除</a></div><p>'
                                    + arr[1]
                                    + '</p><input type="hidden" value="'+preProject+'" id="fileAtt_'+arr[2]+'" name="fileAtts'+id+'" ></input></div>');
                        }
                    }
                },
                allDone : function(obj) {
                    layer.closeAll('loading');
                },
                error : function() {
                    layer.closeAll('loading');
                    layer.msg("上传失败，请稍后再试~", {
                        icon : 7
                    });
                }
            });
    }
  	//删除文件
	function del(index){
		layui.$("#fileAtt_"+index).remove();
		layui.$("#upload_img_"+index).remove();
	}
  
	//根据url查看文件
	function showImg(url){
		var openWin = window.open(url,'','left=410,height=768, width=1024, top=200,  toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');
	}
	function formatNum(num) {
	    var str = num.toString();
	    if (-1 == str.indexOf(".")) {
	        str = str + ".00"
	    }
	    if (-1 != str.indexOf(",")) {
	        str = str.replace(new RegExp(',', "g"), "")
	    }
	    var intSum = str.substring(0, str.indexOf(".")).replace(/\B(?=(?:\d{3})+$)/g, ',');
	    var dot = str.substring(str.length, str.indexOf("."));
	    var ret = intSum + dot;
	    return ret;
	}
	
	//根据承继协议带出需要的字段
	function getContractExtByProId(id) {
		var $ = layui.$, form = layui.form
		$.ajax({
			type : "POST", //提交方式  
			url : "${ctx}/proSettle/getProSettleByProCode",//路径  
			data : {
				"proCodeAndCodes" : id
			},//数据，这里使用的是Json格式进行传输  
			success : function(result) {//返回数据根据结果进行相应的处理 
				if (result.flag == true) {
					
					if(result.contractExtDomain!=null){
						$("#id_proCode")
								.attr("value", result.contractExtDomain.proCode);//项目编号
						if (result.contractExtDomain.orgAreaName != null) {
							$("#id_regionalCompany").attr("value",
									result.contractExtDomain.orgAreaName);//区域公司
						} else {
							$("#id_regionalCompany").attr("value", "暂时为空不可编辑");//区域公司
						}
						if (result.contractExtDomain.orgProName != null) {
							$("#id_projectCompany").attr("value",
									result.contractExtDomain.orgProName);//项目公司
						} else {
							$("#id_projectCompany").attr("value", "暂时为空不可编辑");//项目公司
						}
						$("#areaId").attr("value",
								result.contractExtDomain.hrOrgAreaId);//区域公司id
						$("#compId").attr("value",
								result.contractExtDomain.hrOrgProId);//项目公司id
						$("#sgCityId").attr("value",
								result.contractExtDomain.sgCityId);//项目城市id
						$("#id_ImplementingBody").attr("value",
								result.contractExtDomain.carryOrg);//实施机构
						$("#id_projectLeader").attr("value",
								result.contractExtDomain.proLeader);//项目负责人
					}
					
  
					//项目名称带出项目合同的合同投资信息数据
					var $contractInvestmentInfoPanel = 	$("#contract-investment-info .layui-form-item:nth-child(n+2)");
					var $contractInvestmentInfoBlank = $("#contract-investment-info .layui-form-item:first");
					
					$contractInvestmentInfoPanel.css('display','none');
					$contractInvestmentInfoBlank.css('display','blank');
					
					if(result.contractExtInvest!=null){
						
						$contractInvestmentInfoPanel.css('display','block');
						$contractInvestmentInfoBlank.css('display','none');
						
						$("#caeFeeLabel").text(result.contractExtInvest.caeFee);//建安工程费
						$("#caeFeeId").attr("value", result.contractExtInvest.caeFee);	
						
						$("#caeDownRateLabel").text(result.contractExtInvest.caeDownRate+'%');//建安下浮率(综合）
						$("#caeDownRateId").attr("value", result.contractExtInvest.caeDownRate);
						
						$("#caeRateLabel").text(result.contractExtInvest.caeRate+'%');//建安占比
						$("#caeRateId").attr("value", result.contractExtInvest.caeRate);
						
						$("#prepareFeeLabel").text(result.contractExtInvest.prepareFee);//预备费
						$("#prepareFeeId").attr("value", result.contractExtInvest.prepareFee);
						
						$("#buildOtherFeeLabel").text(result.contractExtInvest.buildOtherFee);//建安工程其他费
						$("#buildOtherFeeId").attr("value", result.contractExtInvest.buildOtherFee);
						
						$("#buildOrgFeeLabel").text(result.contractExtInvest.buildOrgFee);//建设单位管理费
						$("#buildOrgFeeId").attr("value", result.contractExtInvest.buildOrgFee);
						
						$("#gdReplaceFeeLabel").text(result.contractExtInvest.gdReplaceFee);//政府代付费
						$("#gdReplaceFeeId").attr("value", result.contractExtInvest.gdReplaceFee);
						$("#preFeeLabel").text(result.contractExtInvest.preFee);//项目前期费
						$("#preFeeId").attr("value", result.contractExtInvest.preFee);
						
						$("#moveFeeLabel").text(result.contractExtInvest.moveFee);//征地拆迁费
						$("#moveFeeId").attr("value", result.contractExtInvest.moveFee);
						$("#buildInterestLabel").text(result.contractExtInvest.buildInterest);//建设期利息
						$("#buildInterestId").attr("value",
								result.contractExtInvest.buildInterest);
						$("#buyFeeLabel").text(result.contractExtInvest.buyFee);//设备及工器具购置
						$("#buyFeeId").attr("value",
								result.contractExtInvest.buyFee);
						$("#flowFeeLabel").text(result.contractExtInvest.flowFee);//铺底流动资金
						$("#flowFeeId").attr("value",
								result.contractExtInvest.flowFee);
						$("#totalSumLabel").text(result.contractExtInvest.totalSum);//投资合计
						$("#totalSumId").attr("value",result.contractExtInvest.totalSum);
					}
					
					$("#details").html('');
					var tableTemplate = [];
					var ind = 1;
					tableTemplate.push('<tr id="linkRow'+ind+'">');
					tableTemplate.push('<td><input type="text" name="showIdxs" value="'+ind+'" style="border: 0px;width:50px" readonly="readonly" class="layui-input prosettles"></td>');
					tableTemplate.push('<td><input type="text" name="itemNames" lay-verify="required" maxlength="100" autocomplete="off" class="layui-input prosettles"></td>');
					tableTemplate.push('<td id="select_subname"><select id="add_select_subName" name="subNames" lay-verify="required" lay-filter="add_select_subName">');
					tableTemplate.push('</select></td>');
					tableTemplate.push('<td><select id="add_select_feeType" name="feeTypes" lay-verify="required" lay-filter="add_select_feeType"><option value="">请选择</option><option value="1">建安工程费</option>');
					tableTemplate.push('<option value="2">预备费</option><option value="3">建设工程其他费</option><option value="31">建设单位管理费</option><option value="32">政府代付费</option>');
					tableTemplate.push('<option value="33">项目前期费</option><option value="4">建设期利息</option><option value="5">设备及工器具购置</option><option value="6">铺底流动资金</option></select></td>');
					tableTemplate.push('<td><input type="text" name="cotAmountAfters" onblur="calcSumAmount(this);arabiaToCN(this,1);" maxlength="13" lay-verify="required|floatNumber"  autocomplete="off" class="layui-input prosettles"></td>');
					tableTemplate.push('<td><input type="text" name="applyAmounts" id="applyAmount-'+ind+'" onblur="calcSumAmount(this);arabiaToCN(this,1);" maxlength="13" lay-verify="required|floatNumber"  autocomplete="off" class="layui-input prosettles""></td>');
					tableTemplate.push('<td><input type="text" name="checkAmounts" id="checkAmount-'+ind+'" onblur="calcSumAmount(this);arabiaToCN(this,1);" maxlength="13" lay-verify="required|floatNumber"  autocomplete="off" class="layui-input prosettles"></td>');					
					tableTemplate.push('<td><input type="text" name="checkAmountRevises" id="checkAmountRevise-'+ind+'" style="border: 0px;" lay-verify="required|floatNumber" readonly="readonly" class="layui-input prosettles"></td>');
					tableTemplate.push('<td><input type="text" name="checkReviseRates" id="checkReviseRate-'+ind+'" style="border: 0px;" lay-verify="required|floatNumber" readonly="readonly" class="layui-input prosettles"></td>');
					tableTemplate.push('<td><button type="button" class="layui-btn layui-btn-sm" id="addSettleBtn'+ind+'" onclick="addSettleRow(this);"><i class="layui-icon">&#xe654;</i></button>');
					tableTemplate.push('</td>');
					tableTemplate.push('</tr>');
					var $div = $("#details");
                    $div.append(tableTemplate.join(''));
                  	//项目名称带出子项名称集合
					var subList = '<option value="-1">请选择</option>';
					if(result.contractExtSubList.length>0){
						for (var i = 0; i <result.contractExtSubList.length; i++) {
							subList+= '<option value='+result.contractExtSubList[i].subName+'>'+result.contractExtSubList[i].subName+'</option>';
						}
				     }
				    $("#add_select_subName").append(subList);
					form.render();
				}
			}
		});
	}
	//'请输入正确数字，且保留两位小数！'
	function isNumberAndFloat(str) {
		var $ = layui.$, form = layui.form
		if (str.value == '' || str.value == null) {
			return;
		}
		var rgx = /^([-]?)([0-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/;

		var boolrgx = rgx.test(str.value);// true 
		if (boolrgx) {
			return true;
		} else {
			str.value =0;
			layer.msg('请输入正确数字，且保留两位小数！');
		}
	}
	//计算项目合同金额、申报金额、审定金额总价
	function calcSumAmount(obj){
		var $ = layui.$;
		var reg = /^(-)?([1-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/;
		var strCotAmountAfterBuffer =0;
		var strApplyAmountBuffer =0;
		var strCheckAmountBuffer =0;
		var strCheckAmountReviseBuffer =0;
		var strCheckReviseRateBuffer =0;
		
		$('input[name="cotAmountAfters"]').each(function(){
			if(reg.test($(this).val())&&$(this).val()!=''){
				strCotAmountAfterBuffer = parseFloat(strCotAmountAfterBuffer)+ parseFloat($(this).val());
			}else{
				$(this).val(0);
				strCotAmountAfterBuffer = parseFloat(strCotAmountAfterBuffer)+ parseFloat($(this).val());
			}					
		});
		if(strCotAmountAfterBuffer==null||strCotAmountAfterBuffer==''||!reg.test(strCotAmountAfterBuffer)){
			$('#cotAmountAfterId').val('0');
		}else{
			$('#cotAmountAfterId').val(strCotAmountAfterBuffer.toFixed(2));//得到总项目合同金额
		}		
		$('input[name="applyAmounts"]').each(function(){
			if(reg.test($(this).val())&&$(this).val()!=''){
				strApplyAmountBuffer = parseFloat(strApplyAmountBuffer)+ parseFloat($(this).val());
			}else{
				$(this).val(0);
				strApplyAmountBuffer = parseFloat(strApplyAmountBuffer)+ parseFloat($(this).val());
			}							
		});
		if(strApplyAmountBuffer==null||strApplyAmountBuffer==''||!reg.test(strApplyAmountBuffer)){
			$('#applyAmountId').val('0');
		}else{
			$('#applyAmountId').val(strApplyAmountBuffer.toFixed(2));//得到总申报金额
		}			
		$('input[name="checkAmounts"]').each(function(){
			if(reg.test($(this).val())&&$(this).val()!=''){
				strCheckAmountBuffer = parseFloat(strCheckAmountBuffer)+ parseFloat($(this).val());
			}else{
				$(this).val(0);
				strCheckAmountBuffer = parseFloat(strCheckAmountBuffer)+ parseFloat($(this).val());
			}					
		});
		if(strCheckAmountBuffer==null||strCheckAmountBuffer==''||!reg.test(strCheckAmountBuffer)){
			$('#checkAmountId').val('0');
		}else{
			$('#checkAmountId').val(strCheckAmountBuffer.toFixed(2));//得到总审定金额
			$('#id_totalSum').val(strCheckAmountBuffer.toFixed(2));//本次预(结）算金额(元）赋值	
		}
		
		$('input[name="applyAmounts"]').each(function(){
			var applyAmount = $(this).val();//得到该行申报金额			
			var curId = $(this).attr('id');
			var checkAmountId = 'checkAmount-'+ curId.split('-')[1];
			var checkAmount = $('#'+checkAmountId).val();//得到该行审定金额	
			var checkAmountReviseId = 'checkAmountRevise-'+ curId.split('-')[1];
			var checkAmountRevise = (parseFloat(checkAmount)).toFixed(2) - (parseFloat(applyAmount)).toFixed(2);			
			$('#'+checkAmountReviseId).val(checkAmountRevise.toFixed(2));//计算该行审核增减金额
			
			var checkReviseRateId = 'checkReviseRate-'+ curId.split('-')[1];
			var checkReviseRate = (checkAmountRevise/applyAmount)*100;
			$('#'+checkReviseRateId).val(checkReviseRate.toFixed(2));//计算该行审核增减率			
		});
		$('input[name="checkAmountRevises"]').each(function(){
			if(reg.test($(this).val())&&$(this).val()!=''){
				strCheckAmountReviseBuffer = parseFloat(strCheckAmountReviseBuffer)+ parseFloat($(this).val());
			}else{
				$(this).val(0);
				strCheckAmountReviseBuffer = parseFloat(strCheckAmountReviseBuffer)+ parseFloat($(this).val());
			}						
		});
		$('#checkAmountReviseId').val(strCheckAmountReviseBuffer.toFixed(2));//得到总审核增减金额
		$('input[name="checkReviseRates"]').each(function(){
			if(reg.test($(this).val())&&$(this).val()!=''){
				strCheckReviseRateBuffer = parseFloat(strCheckReviseRateBuffer)+ parseFloat($(this).val());
			}else{
				$(this).val(0);
				strCheckReviseRateBuffer = parseFloat(strCheckReviseRateBuffer)+ parseFloat($(this).val());
			}					
		});
		var applyAmountStr = $('#applyAmountId').val();
		var checkAmountReviseStr = $('#checkAmountReviseId').val();
		strCheckReviseRateBuffer = parseFloat(checkAmountReviseStr/applyAmountStr)*100;
		if(strCheckReviseRateBuffer==''||strCheckReviseRateBuffer==null
				||isNaN(strCheckReviseRateBuffer)||strCheckReviseRateBuffer==Infinity){
			$('#checkReviseRateId').val(0);
		}else{
			$('#checkReviseRateId').val(strCheckReviseRateBuffer.toFixed(2));//得到平均审核增减率	
		}		
	}
	//新增预结算一行
	function addSettleRow(t){
		var $ = layui.$;
		var delBtnCount = $("button[id^='delSettleBtn']").length;
		/* if(delBtnCount == 1){
			$("button[id^='delSettleBtn']").each(function(){
				$(this).removeAttr("style");
			});
		} */
		var thisid = $(t).attr("id").substring(12);
		thisid = $("tr[id=linkRow" + thisid + "]").find("td:first").find("input").val();
		thisid = parseInt(thisid);
		var nextIndex = parseInt(thisid) + 1;
		var maxInd = $("tr[id^='linkRow']").length;
		$("tr[id^='linkRow']").each(function(){
			$linkRow = $(this);
			var tId = $(this).attr("id").substring(7);
			tId = parseInt(tId);
		  	if(tId > maxInd){
		  		maxInd = parseInt(tId);
		  	}
		  	var thisIndex = $(this).find("td:first").find("input").val();
		  	thisIndex = parseInt(thisIndex);
		  	var nextId = thisIndex + 1;
		  	if(thisIndex > thisid) {
		  		$("tr[id=linkRow" + tId + "]").find("td:first").find("input").val(nextId);
		  		$linkRow.find(".layui-input").each(function(){
		  			if($(this).attr("id") != null && $(this).attr("id") != ''){		  				
		  				var inputName = $(this).attr("id").split("-");
		  				var inpName = inputName[0]+"-"+nextId;
		  				$(this).attr("id",inpName);
		  			}
		  		});
		  	}		  	
		});
		
		var ind = maxInd + 1;		
		var medalHtml = '';
		var add_select_subName = $("#select_subname").clone();
		medalHtml += '	<tr id="linkRow'+ind+'">';
		medalHtml += '	<td><input type="text" name="showIdxs" value="'+nextIndex+'" style="border: 0px;width:50px" readonly="readonly" class="layui-input prosettles"></td>';
		medalHtml += '	<td><input type="text" name="itemNames" maxlength="100" lay-verify="required"  autocomplete="off" class="layui-input prosettles"></td>'
		medalHtml += '	<td>'+add_select_subName.html()+'</td>';
		medalHtml += '  <td><select id="add_select_feeType" name="feeTypes" lay-verify="required" lay-filter="add_select_feeType"><option value="">请选择</option><option value="1">建安工程费</option>';
		medalHtml += '  <option value="33">项目前期费</option><option value="4">建设期利息</option><option value="5">设备及工器具购置</option><option value="6">铺底流动资金</option></select></td>';
		medalHtml += '  <td><input type="text" name="cotAmountAfters" onblur="calcSumAmount(this);arabiaToCN(this,1);" maxlength="13" lay-verify="required|floatNumber" autocomplete="off" class="layui-input prosettles"></td>';
		medalHtml += ' <td><input type="text" name="applyAmounts" id="applyAmount-'+nextIndex+'" onblur="calcSumAmount(this);arabiaToCN(this,1);" maxlength="13" lay-verify="required|floatNumber"  autocomplete="off" class="layui-input prosettles"></td>';
		medalHtml += ' <td><input type="text" name="checkAmounts" id="checkAmount-'+nextIndex+'" onblur="calcSumAmount(this);arabiaToCN(this,1);" maxlength="13" lay-verify="required|floatNumber"  autocomplete="off" class="layui-input prosettles"></td>';					
		medalHtml += ' <td><input type="text" name="checkAmountRevises" id="checkAmountRevise-'+nextIndex+'" style="border: 0px;" lay-verify="required|floatNumber" readonly="readonly" class="layui-input prosettles"></td>';
		medalHtml += ' <td><input type="text" name="checkReviseRates" id="checkReviseRate-'+nextIndex+'" style="border: 0px;" lay-verify="required|floatNumber" readonly="readonly" class="layui-input prosettles"></td>';
		medalHtml += ' <td><button type="button" class="layui-btn layui-btn-sm" id="addSettleBtn'+ind+'" onclick="addSettleRow(this);"><i class="layui-icon">&#xe654;</i></button>';
		medalHtml += ' <button type="button" class="layui-btn layui-btn-sm" id="delSettleBtn'+ind+'" onclick="delSettleRow('+ind+')"><i class="layui-icon">&#xe640;</i></button></td>';
		medalHtml += '</tr>';	    	   	
			    
		$(t).parent().parent().after(medalHtml);
		layui.form.render();
	}
	//删除预结算一行
	function delSettleRow(id){
		var $ = layui.$;
		layui.layer.confirm('确定删除？',{icon:3, title :'提示'}, function(index){			
			var thisid = $("tr[id=linkRow" + id + "]").find("td:first").find("input").val();
	    	thisid = parseInt(thisid);
	    	$("tr[id^='linkRow']").each(function(){
	    		$linkRow = $(this);
				var tId = $(this).attr("id").substring(7);
				tId = parseInt(tId);
			  	var thisIndex = $("tr[id=linkRow" + tId + "]").find("td:first").find("input").val();
			  	thisIndex = parseInt(thisIndex);
			  	var nextId = thisIndex - 1;
			  	if(thisIndex > thisid) {
			  		$("tr[id=linkRow" + tId + "]").find("td:first").find("input").val(nextId);
			  		$linkRow.find(".layui-input").each(function(){
			  			if($(this).attr("id") != null && $(this).attr("id") != ''){		  				
			  				var inputName = $(this).attr("id").split("-");
			  				var inpName = inputName[0]+"-"+nextId;
			  				$(this).attr("id",inpName);
			  			}
			  		});
			  	}
			});
	    	var strCotAmountAfter = $("tr[id='linkRow" + id + "']").find("input[name='cotAmountAfters']").val().toFloat();
			var strApplyAmount = $("tr[id=linkRow" + id + "]").find("input[name='applyAmounts']").val().toFloat();
			var strCheckAmount = $("tr[id=linkRow" + id + "]").find("input[name='checkAmounts']").val().toFloat();
			var strCheckAmountRevise = $("tr[id=linkRow" + id + "]").find("input[name='checkAmountRevises']").val().toFloat();
			var strCheckReviseRate = $("tr[id=linkRow" + id + "]").find("input[name='checkReviseRates']").val().toFloat();
			
			//减行时重新计算项目合同金额
			var cotAmountAfterStr = $('#cotAmountAfterId').val().toFloat();
			var cotAmountAfterNewStr = cotAmountAfterStr - strCotAmountAfter;
			$('#cotAmountAfterId').val(cotAmountAfterNewStr.toMoney());
			
			//减行时重新计算申报金额
			var applyAmountStr = $('#applyAmountId').val().toFloat();
			var applyAmountNewStr = applyAmountStr - strApplyAmount;
			$('#applyAmountId').val(applyAmountNewStr.toMoney());
			
			//减行时重新计算审定金额
			var checkAmountStr = $('#checkAmountId').val().toFloat();
			var checkAmountNewStr = checkAmountStr - strCheckAmount;
			$('#checkAmountId').val(checkAmountNewStr.toMoney());
			//本次预（结）算金额（元）重新赋值
			$('#id_totalSum').val(checkAmountNewStr.toMoney());
			
			//减行时重新计算审核增减金额
			var checkAmountReviseStr = $('#checkAmountReviseId').val().toFloat();
			var checkAmountReviseNewStr = parseFloat(checkAmountReviseStr)-parseFloat(strCheckAmountRevise);
			$('#checkAmountReviseId').val(checkAmountReviseNewStr.toMoney());
			
			//减行时重新计算审核增减率
			var checkAmountReviseString = $('#checkAmountReviseId').val().toFloat();
			var applyAmountString = $('#applyAmountId').val().toFloat();
			var checkReviseRateNewStr = (checkAmountReviseString/applyAmountString)*100
			$('#checkReviseRateId').val(checkReviseRateNewStr.toMoney());
			
	    	$("#linkRow"+id).remove();
			layui.layer.close(index);	
						
 		});

	}
</script>